<?php
defined('_JEXEC') or die('Restricted access');

$jversion = new JVersion();
$j15 = ($jversion->RELEASE == '1.5');

$order = $this->field->ordering;
if ($this->isNew) {
  $order = $this->maxorder;
}

?>
<style type="text/css">

.icon-48-fields {
  background-image: url('components/com_nspro/img/fields48.png');
}

</style>
<script type="text/javascript"><!--

var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

var posX = 0
var posY = 0

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    posX = event.clientX + document.body.scrollLeft
    posY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    posX = e.pageX
    posY = e.pageY
  }  
  // catch possible negative values in NS4
  if (posX < 0){posX = 0}
  if (posY < 0){posY = 0}  
  return true;
}

--></script>
<script type="text/javascript"><!--

  var rshowing = 0;
  var ishowing = 0;
  
  function toggleRegexp() {
    if (rshowing == 0) {
      document.getElementById('regexptooltip').setAttribute('style', 'visibility: normal; max-width: 350px; position: absolute; left: '+posX+'px; top: '+posY+'px;');
      rshowing = 1;
    }
    else {
      document.getElementById('regexptooltip').setAttribute('style', 'visibility: hidden; position: absolute;');
      rshowing = 0;
    }
  }

  function toggleInitialValue() {
    if (ishowing == 0) {
      document.getElementById('inittooltip').setAttribute('style', 'visibility: normal; max-width: 350px; position: absolute; left: '+posX+'px; top: '+posY+'px;');
      ishowing = 1;
    }
    else {
      document.getElementById('inittooltip').setAttribute('style', 'visibility: hidden; position: absolute;');
      ishowing = 0;
    }
  }

--></script>
<div id="regexptooltip" class="tool-tip tip-wrap" style="position: absolute; left: 177px; top: 159px; visibility: hidden;">
<div class="tip-top"></div>
<div class="tip">
<div class="tool-title tip-title"><span>NS Pro Validation Regular Expressions</span></div>
<div class="tool-text tip-text">
<span>You can use this field to validate the user's input. If not valid, NS Pro's Subscription Form will produce an error.<br/>
Here is a list of the "smart" Regular Expression shortcuts you can use.<br/>
<ol>
<li><b>#email#</b> if you want to validate an email.<hr></li>
<li><b>#us_state_code#</b> if you want to validate a USA State Code</li>
<li><b>#us_zip_code#</b> if you want to validate a USA Zip Code<hr></li>
<li><b>#canada_postal_code#</b> if you want to validate a Canada Postal Code</li>
<li><b>#uk_postal_code#</b> if you want to validate a UK Postal Code<hr></li>
<li><b>#north_america_phone#</b> if you want to validate a Phone Number from North America<hr></li>
<li><b>#ip_address#</b> if you want to validate an IP Address<hr></li>
</ol>
<a href="mailto:mavrosxristoforos@gmail.com?subject=NS Pro: I would like to suggest a field regular expression." target="_blank">Suggest a new Regular Expression</a>
</span>
</div></div>
<div class="tip-bottom"></div>
</div>

<div id="inittooltip" class="tool-tip tip-wrap" style="position: absolute; left: 177px; top: 159px; visibility: hidden;">
<div class="tip-top"></div>
<div class="tip"><div class="tool-title tip-title"><span>NS Pro Field Initial Value</span></div>
<div class="tool-text tip-text">
<span>You can use this field to initiate a field's value.<br/>
For dropdowns, radio buttons and checkbox fields this field should contain the field's options.<br/>
Example: Field Option 1,Field Option 2,Field Option 3<br/>
<br/>You can also use one of the following "smart" initial values, for text or hidden fields:<br/>
<ol>
<li><b>#subscriber_ip#</b> to get the Subscriber's IP Address</li>
<li><b>#page_url#</b> to get the page in which the Subscriber subscribed</li>
<li><b>#web_browser#</b> to get the Subscriber's Web Browser</li>
<li><b>#operating_system#</b> to get the Subscriber's OS</li>
</ol>
</span>
</div></div>
<div class="tip-bottom"></div>
</div>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<div class="col width-10 <?php if ($j15 != true) { print 'fltlft'; } ?>">
    <fieldset class="adminform">
        <legend><?php echo JText::_( 'Details' ); ?></legend>

        <table class="admintable <?php if ($j15 != true) { print 'adminform'; } ?>">
        <tr>
            <td width="100" class="key">
                <label for="name">
                    <?php echo JText::_( 'Name' ); ?>:
                </label>
            </td>
            <td>
                <input class="inputbox" type="text" name="name" id="name" size="60 " maxlength="250"
                value="<?php echo $this->field->name;?>" />
            </td>
        </tr>
        <tr>
            <td width="110" class="key">
                <label for="fieldtype">
                    <?php echo JText::_( 'Field Type' ); ?>:
                </label>
            </td>
            <td>
                <select class="inputbox" name="fieldtype" id="fieldtype" style="width: 267px;">
                <?php
                  $n = count($this->ftypes);
                  for ($i = 0; $i < $n; $i++) {
                    print '<option value="'.$i.'"';
                    if ($i == $this->field->fieldtype) {
                      print ' selected="selected"';
                    }
                    print '>'.$this->ftypes[$i].'</option>';
                  }
                ?>
                </select>
            </td>
        </tr>
        <tr>
            <td width="110" class="key">
                <label for="regexp">
                    <?php echo JText::_( 'Validation Regular Expression' ); ?>:
                </label>
            </td>
            <td>
                <input class="inputbox" type="text" name="regexp" id="regexp" size="53" value="<?php echo $this->field->regexp; ?>" />
                &nbsp;<input class="button" type="button" value="?" style="width: 21px;" onClick="javascript:toggleRegexp();"/>
            </td>
        </tr>
        <tr>
            <td width="120" class="key">
                <?php echo JText::_( 'Required' ); ?>:
            </td>
            <td>
                <?php if ($j15 != true) { print '<fieldset class="radio inputbox">'; } ?>
                <?php echo JHTML::_( 'select.booleanlist',  'required', 'class="inputbox"', $this->field->required ); ?>
                <?php if ($j15 != true) { print '</fieldset>'; } ?>
            </td>
        </tr>
        <tr>
            <td width="120" class="key">
                <?php echo JText::_( 'Published' ); ?>:
            </td>
            <td>
                <?php if ($j15 != true) { print '<fieldset class="radio inputbox">'; } ?>
                <?php echo JHTML::_( 'select.booleanlist',  'published', 'class="inputbox"', $this->field->published ); ?>
                <?php if ($j15 != true) { print '</fieldset>'; } ?>
            </td>
        </tr>
        <tr>
            <td width="120" class="key">
                <?php echo JText::_( 'Show on Subscriber Manager' ); ?>:
            </td>
            <td>
                <?php if ($j15 != true) { print '<fieldset class="radio inputbox">'; } ?>
                <?php echo JHTML::_( 'select.booleanlist',  'show_backend', 'class="inputbox"', $this->field->show_backend ); ?>
                <?php if ($j15 != true) { print '</fieldset>'; } ?>
            </td>
        </tr>
        <tr>
            <td width="120" class="key">
                <?php echo JText::_( 'Field Position' ); ?>:
            </td>
            <td>
                <?php

                  $positions = array();

                  $pos1 = new stdClass();
                  $pos1->value = '1';
                  $pos1->text = JText::_('Above Form');
                  $positions[] = $pos1;

                  $pos1 = new stdClass();
                  $pos1->value = '0';
                  $pos1->text = JText::_('Below Form');
                  $positions[] = $pos1;

                  if ($j15 != true) { print '<fieldset class="radio inputbox">'; }
                  echo JHTML::_( 'select.radiolist', $positions, 'abovepos', 'class="inputbox"', 'value', 'text', $this->field->abovepos );
                  if ($j15 != true) { print '</fieldset>'; }
                ?>
            </td>
        </tr>
        <tr>
            <td width="110" class="key">
                <label for="value">
                    <?php echo JText::_( 'Initial Value' ); ?>:
                </label>
            </td>
            <td>
                <input class="inputbox" type="text" name="value" id="value" size="53" value="<?php echo $this->field->value; ?>" />
                &nbsp;<input class="button" type="button" value="?" style="width: 21px;" onClick="javascript:toggleInitialValue();"/>
            </td>
        </tr>
        <!--<tr>
            <td width="110" class="key">
                <label for="ordering">
                    <?php echo JText::_( 'Order' ); ?>:
                </label>
            </td>
            <td>
                <input class="inputbox" type="text" name="ordering" id="ordering" size="60" value="<?php echo $this->field->ordering; ?>" />
            </td>
        </tr>-->
        <tr>
            <td width="110" class="key">
                <label for="notes">
                    <?php echo JText::_( 'Notes' ); ?>:
                </label>
            </td>
            <td>
                <input class="inputbox" type="text" name="notes" id="notes" size="60" value="<?php echo $this->field->notes; ?>" />
            </td>
        </tr>
        </table>
    </fieldset>
</div>
<div class="clr"></div>

<input type="hidden" name="option" value="com_nspro" />
<input type="hidden" name="id" value="<?php echo $this->field->id; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="nspro" />
<input type="hidden" name="ordering" value="<?php print $order; ?>"/>
</form>

<small><i>NS Pro by <a href="http://www.mavrosxristoforos.com/">Mavrosxristoforos.com</a> Copyright 2009-2011</i></small>